#include <iostream>
#define ll long long

using namespace std;

int main(){
	
	ll n,k;
	cin >> n >> k;
	
	if(n == 1) {
		cout << -1;
		return 0;
	}
	
	ll sum = (k+2) * (k-1) /2 -(k-2);
	
	ll count = 0;
	
	if(sum < n){
		cout << -1;
	}else if(sum == n){
		cout << k-1;
	}else{
		
		if(n <= k){
			cout << 1;
			return 0;
		}
		
		ll l = 1, r = k-2;
		while(l <= r){
			ll mid = l + (r - l) / 2;
			if((k-2+mid) * (k -1 - mid) / 2 >= n - k){
				l = mid + 1;
			}else{
				r = mid - 1;
			}
		}
		
		count = k - r;
	
		cout << count;
	}
	
	return 0;
}
